import  re
import requests
url = "https://movie.douban.com/top250"
headers = {"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"}
resp = requests.get(url, headers=headers)
page_conteent = resp.text
print(resp.text)

obj = re.compile(r'<li>.*?<div class="item">.*?<span class="title">(?P<name>.*?)</span>',re.S)
result = obj.finditer(page_conteent)
for it in result:
    print(it.group("name"))
#成功
#(?P<name>.*?)p要大写
#可以先打印出来再匹配
#.*？表示任何字符包括空格